<?php

//  $Id: TwModelMulti.class.php 226 2010-03-31 13:47:23Z cgb $
//  $HeadURL: http://121.52.216.232/svn/TalentWalkerBase/trunk/web/TalentWalker/TwModelMulti.class.php $
//  Copyright(c)@2010  Talent Walker 

/**  一对多的表 */

class DnModelMulti extends DnModelBase // implements ITwModel
{
	public $id;
	public $sub_key = '';
	public $data = array();
	public function __construct($id = 0, $opt = 0) {
		return parent :: __construct($id, $opt);
	}
	protected function setDataToDataBase($data) {
		foreach ($data as $key => $value) {
			if ($value == $this->init_data[$key]) {
				continue;
			}
			$value[$this->sub_key] = $key;
			$this->_replaceData($value, $this->real_table_name, $this->id, $this->table_prikey);
		}
	}
	///////////////////////////////////////////////////////////////////////////
	public function create() {
		foreach ($this->data as $sub_id => $value) {
			$value[$this->sub_key] = $sub_id;
			$this->_insertData($value, $this->real_table_name, $this->id, $this->table_prikey);
		}
		return $this;
	}
}